

# 带自编译的Dockerfile
# alpine的源配置的是ustc.可以更换的.

# complie
FROM golang:1.19-alpine AS golang
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
        && apk add git \
        && go env -w GOPROXY=https://goproxy.cn,direct \
        && go env -w GO111MODULE="auto" \
        && git clone https://gitee.com/cynen/monitor-go.git \
        && cd monitor-go/prometheus-port-probe \
        && CGO_ENABLE=0 go build -o port-probe


# build images

FROM alpine:3.17
ENV LANG C.UTF-8
ENV TZ=Asia/Shanghai
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
    && apk update && apk upgrade \
    && apk add ca-certificates\
    && update-ca-certificates \
    && apk --no-cache add openssl wget \
    && apk add --no-cache bash tzdata curl \
    && set -ex \
    && mkdir -p /usr/bin \
    && mkdir -p /usr/sbin
# 待完善.
COPY --from=golang /go/monitor-go/prometheus-port-probe/port-probe /usr/bin/
# 将配置文件也copy进去.
COPY config.yml /etc/

ENTRYPOINT ["port-probe"]
CMD ["-c","/etc/config.yml"]